﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Streambolics
{
    public class IniSection
    {
        private string _Name;
        private IniFile _File;
        private Dictionary<string, IniKey> _Values = new Dictionary<string, IniKey> ();

        internal IniSection (IniFile aFile, string aName)
        {
            _File = aFile;
            _Name = aName;
        }

        public void SetValue (string aValueName, string aValue)
        {
            _File.SetValue (_Name, aValueName, aValue);
        }

        public string GetValue (string aValueName, string aDefault)
        {
            return _File.GetValue (_Name, aValueName, aDefault);
        }

        public IniKey Value (string aName)
        {
            string uName = aName.ToUpper ();
            if (_Values.ContainsKey (uName))
            {
                return _Values[uName];
            }
            else
            {
                IniKey s = new IniKey (this, aName);
                _Values.Add (uName, s);
                return s;
            }
        }

        public IniKey this[string aName]
        {
            get
            {
                return Value (aName);
            }
        }
    }
}
